import * as types from '@/store/mutations-types'
import Token from '@/ck/util/token'

//获取学期的接口
import Semester from '../model/semester'

const actions = {
  setUserAndState ({ commit }, user) {
    // 如果登陆成功，设置logined标志位
    commit(types.SET_LOGINED)
    // 设置全局用户状态
    commit(types.SET_USER, user)
  },
  loginOut ({ commit }) {
    Token.removeToken()
    commit(types.REMOVE_LOGINED)
  },

  //获取当前启用学期，res中包含着当前启用学期的信息
  getCurrentSemester (context) {
    return new Promise((resolve ,reject)=>{
      const res = Semester.GetCurrentSemester()
      resolve(res)
    })
  },


}

export default actions
